﻿using System;
using System.Collections.Generic;

using System.Text;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
namespace DataProvider
{
    public class SqlBlock
    {
        private String id;

        public String Id
        {
            get { return id; }
            set { id = value; }
        }
        private String sql;

        public String Sql
        {
            get { return sql; }
            set { sql = value; }
        }

        private SqlType sqlType = SqlType.Text;

        public SqlType SqlType
        {
            get { return sqlType; }
            set { sqlType = value; }
        }
        private List<DbParameter> parameters = new List<DbParameter>();
        public List<DbParameter> Parameters
        {
            get { return this.parameters; }
        }
        private String resultClass = "";

        public String ResultClass
        {
            get { return resultClass; }
            set { resultClass = value; }
        }

        public SqlBlock CloneSelf()
        {
            SqlBlock newInstance = new SqlBlock();
            newInstance.Id = this.id;
            newInstance.Sql = this.sql;
            newInstance.SqlType = this.sqlType;
            newInstance.ResultClass = this.resultClass;
            return newInstance;
        }
    }

    public enum SqlType
    {
        Text,
        StoreProcedure,
    }


    public class SqlStatemate
    {
        public String Sql = "";
        public SqlStatemate()
        {

        }
        public SqlStatemate(String sql, params DbParameter[] paras)
        {
            this.Sql = sql;
            if(paras != null)
            {
                this.Parameters.AddRange(paras);
            }
        }
        public List<DbParameter> Parameters = new List<DbParameter>();
    }

    public enum DBType
    {
        SQLServer,
        Access,
        Excel,
        SQLite,
        MySQL
    }
}
